import { defineConfig } from "vite";
import svgr from "vite-plugin-svgr";
import react from "@vitejs/plugin-react";
import autoprefixer from "autoprefixer";
import { fileURLToPath, URL } from "node:url";
import { createHtmlPlugin } from "vite-plugin-html";

// https://vitejs.dev/config/
export default defineConfig(config => {
  const envDir = "./env";
  const envPrefix = ["ENV"];

  return {
    envDir,
    envPrefix,
    server: {
      host: '0.0.0.0'
    },
    build: {
      outDir: "./build"
    },
    css: {
      postcss: {
        plugins: [autoprefixer(["Last 5 versions"])],
      },
    },
    resolve: {
      alias: {
        "@": fileURLToPath(new URL("./src", import.meta.url)),
      },
    },
    plugins: [
      react(),
      svgr(),
      createHtmlPlugin(),
    ],
  };
});
